
package Bean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class stock {
    private String kodetoko;
    private String kodebarang;
    private String nama;
    private Integer jumlah;

    public stock() {
    }
    public String getNama() {
        return nama;
    }
    public void setNama(String nama) {
        this.nama = nama;
    }
    public String getKodetoko() {
        return kodetoko;
    }
    public void setKodetoko(String kode_toko) {
        this.kodetoko = kode_toko;
    }
    public String getKodebarang() {
        return kodebarang;
    }
    public void setKodebarang(String kode_barang) {
        this.kodebarang = kode_barang;
    }
    public Integer getJumlah() {
        return jumlah;
    }
    public void setJumlah(Integer jumlah) {
        this.jumlah = jumlah;
    }
    public List tampil () throws SQLException {
        List stok = new ArrayList();
//        Connection conn = DataBaseConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "12345");
        Connection conn = DataBaseConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs115314009", "mhs115314009");
        String retrieveQuery = "select s.kode_toko,s.kode_barang, b.nama_barang, s.jumlah from stock s, barangrplt b where b.kode_barang= s.kode_barang";
            Statement st = conn.createStatement();
            ResultSet rs = st.executeQuery(retrieveQuery);
            while (rs.next()) {
                stock stokx = new stock();
                barang brg =new barang();
                stokx.setKodetoko(rs.getString(1));
                stokx.setKodebarang(rs.getString(2));
                stokx.setNama(rs.getString(3));
                stokx.setJumlah(rs.getInt(4));
                stok.add(stokx);
            }
        conn.commit();
        return stok;
    }
    
    
}
